namespace go thrift.generated
namespace java xyz.itao.thrift.generated

#typedef取别名
typedef i16 short
typedef i32 int
typedef i64 long
typedef bool boolean
typedef string String

# struct 结构体，对应于java的类
struct User{
    1: optional long id,
    2: optional String username,
    3: optional boolean admin,
    4: optional int age,
    # list 当于ArrayList
    5: optional list<User> friends,
    # set 相当于HashSet
    6: optional set<String> ips,
    # map 相当于HashMap
    7: optional map<String, User> relatives
}
# exception 对于java的异常
exception DataException {
    1: optional int code,
    2: optional String message,
    3: optional String callStack
}
# service 服务，定义服务的类
service UserService{
    # [返回值] [方法名] (方法参数) throws (异常)
    User getUserByUsername(1: required String username) throws (1: DataException dataException),
    # 没有返回值用void
    void saveUser(1: required User user) throws (1: DataException dataException)
}